import type { RouteRecordRaw } from 'vue-router';
/**
 * 路由meta对象参数说明
 * meta: {
 *      title:          菜单栏及 tagsView 栏、菜单搜索名称（国际化）
 *      hidden：        是否隐藏此路由
 *      icon：          菜单、tagsView 图标，阿里：加 `iconfont xxx`，fontawesome：加 `fa xxx`
 * }
 */

/**
 * 静态路由（默认路由 - 常量路由）
 */
export const staticRoutes: Array<RouteRecordRaw> = [
  //    /login 登录一级路由
  {
    path: '/login',
    name: 'Login',
    component: () => import('@/views/login/index.vue'),
    meta: {
      hidden: true // 控制是否在侧边栏展示
    }
  },
  //     /404   404一级路由
  {
    path: '/404',
    name: '404',
    component: () => import('@/views/error/404.vue'),
    meta: {
      hidden: true // 控制是否在侧边栏展示
    }
  },
  // 反斜杠
  {
    path: '/',
    component: () => import('@/layout/index.vue'),
    redirect: '/home',
    children: [{
      path: 'home',
      name: 'Home',
      component: () => import('@/views/home/index.vue'),
      meta: {
        title: '首页',
        icon: 'ele-HomeFilled',
      }
    }]
  },
];

// 异步路由: 需要和返回的个人信息中的 routes 尽心筛选的路由
export const asyncRoutes: Array<RouteRecordRaw> = [
  // 权限管理
  {
    name: 'Acl',
    path: '/acl',
    component: () => import('@/layout/index.vue'),
    redirect: '/acl/user/list',
    meta: { title: '权限管理', icon: 'ele-Setting' },
    children: [
      {
        name: 'User',
        path: '/acl/user/list',
        component: () => import('@/views/acl/user/index.vue'),
        meta: { title: '用户管理' }
      },
      {
        name: 'Role',
        path: '/acl/role/list',
        component: () => import('@/views/acl/role/index.vue'),
        meta: {
          title: '角色管理',
        },
      },
      {
        name: 'RoleAuth',
        path: '/acl/role/auth',
        component: () => import('@/views/acl/role/roleAuth.vue'),
        meta: {
          title: '角色管理',
          hidden: true,
          activeMenu: '/acl/role/list',
        },
      },
      {
        name: 'Permission',
        path: '/acl/permission/list',
        component: () => import('@/views/acl/permission/index.vue'),
        meta: {
          title: '菜单管理',
        }
      }
    ]
  },
  //商品管理路由
  //将来后台管理系统项目:将来要做路由权限,一级、二级、三级路由组件
  //命名路由,路由名字老师叫什么,你们的需要相同
  {
    path: '/product',
    component: () => import('@/layout/index.vue'),
    meta: {
      title: '商品管理',
      icon: 'ele-Tickets'
    },
    name:'Product',
    children: [
      {
        name:"Trademark",
        path: 'trademark',
        component: () => import('@/views/product/trademark/index.vue'),
        meta: {
          title: '品牌管理',
          icon: 'ele-Menu'
        }
      },
      {
        name:'Attr',
        path: 'attr',
        component: () => import('@/views/product/attr/index.vue'),
        meta: {
          title: '平台属性管理',
          icon: 'ele-Expand'
        }
      }
      ,
      {
        name:'Spu',
        path: 'spu',
        component: () => import('@/views/product/spu/index.vue'),
        meta: {
          title: "SPU管理",
          icon: 'ele-Iphone'
        }
      },
      {
        name:'Sku',
        path: 'sku',
        component: () => import('@/views/product/sku/index.vue'),
        meta: {
          title: "SKU管理",
          icon: 'ele-LocationInformation'
        }
      },
      // 测试页面 - 讲解scoped作用
      {
        name:'Scoped',
        path: 'scoped',
        component: () => import('@/views/product/scoped/index.vue'),
        meta: {
          title: "scoped作用",
          icon: 'ele-LocationInformation'
        }
      },
    ]
  },
  {
    name: 'Finance', // 这个name是来和当前登录用户返回的个人信息中的routes进行匹配的
    path: '/finance',
    component: () => import('@/layout/index.vue'),
    meta: {
      title: '财务管理',
      icon: 'ele-Tickets'
    },
    children: [
      {
        name: 'Salary', 
        path: 'salary',
        component: () => import('@/views/finance/salary/index.vue'),
        meta: {
          title: '薪资管理',
        }
      },
      {
        name: 'Tax',
        path: 'tax',
        component: () => import('@/views/finance/tax/index.vue'),
        meta: {
          title: '税务管理',
        }
      }
    ]
  }
]

/* 匹配任意的路由 必须最后注册 */
// 任意路由: 输入任意的url,进行匹配,匹配这个不存在的路由重定向到404
export const anyRoute: RouteRecordRaw = {
  path: '/:pathMatch(.*)',
  name: 'Any',
  redirect: '/404',
  meta: {
    hidden: true
  }
}


